<template>
	<view>
		<view class="choujiang">
			<image class="prize" src="@/static/images/newhone/good.jpg"></image>
			<view class="tabs">
				<view class="li active">综合</view>
				<view class="li">价格</view>
				<view class="li">上新</view>
			</view>
			<swiper class="noticeBox" circular acceleration :display-multiple-items="3" :vertical="true"
				:autoplay="true" next-margin="0px" previous-margin="0px" :interval="1000" :duration="3400">
				<swiper-item v-for="(item,index) in notice" :key="index">
					<view class="item" style="background-color: aquamarine;">
						<image class="avatar" :src="item.avatar"></image>
						<text class="name">{{item.user_name.substr(0,1)}}**开出了{{item.goods_name}}</text>
						<text class="type">{{item.type}}</text>
					</view>
				</swiper-item>
			</swiper>
			<scroll-view scroll-y="true" class="scrollView">
				<view class="list" v-for="item in blindBoxList" :key="item.id" @click="openbox(item)">
					<view class="l">
						<image :src="item.cover_image"></image>
					</view>
					<view class="r">
						<view class="name">{{item.name}}</view>
						<view class="price">￥{{item.first_blood}}</view>
						<view class="prob">
							史诗{{item.ss}}% 稀有{{item.xy}}%
							<br>
							传说{{item.cs}}% 普通{{item.pt}}%
						</view>
						<view class="goods">
							<image v-for="good in item.legend_goods" :key="good.goods_id" :src="good.cover_image">
							</image>
						</view>
					</view>
				</view>
			</scroll-view>
		</view>
		<tabBar :currentPage="4" :messageNum="messageNum" />
	
	</view>
</template>

<script>
	import tabBar from '@/components/tabBar';
	export default {
		components: {
			tabBar,
		},
		data() {
			return {
				messageNum: 0,
				blindBoxList: [],
				allFilterGoodslist: [],
				notice: [],
			
			}
		},
		onLoad() {
			// console.log(uni.getStorageSync('token'),"uni.getStorageSync('token')");
			this.getBlindboxlist()
			if (uni.getStorageSync('token')) {
				this.rollnotice()
			}
			setInterval(() => {
				this.rollnotice()
			}, 10000)
		},
		methods: {
			rollnotice() {
				this.$api.rollnotice().then(res => {
					this.notice = res;
				});
			},
			openbox(item) {
				if (!uni.getStorageSync('token')) {
					uni.showModal({
						title: '温馨提示',
						content: '登录后可继续操作，是否登录？',
						success: res => {
							if (res.confirm) {
								uni.navigateTo({
									url: '/pages/login/login'
								});
							}
						}
					});
				} else {
					const param = encodeURIComponent(JSON.stringify({
						id: item.id,
						name: item.name,
						pt: item.pt,
						setting_id: item.setting_id,
						ss: item.ss,
						xy: item.xy,
						first_blood: item.first_blood,
						label_name: item.label_name,
						cover_image: item.cover_image,
						cs: item.cs,
						activity_describe: item.activity_describe,
						consume_num: item.consume_num
					}))
					uni.navigateTo({
						url: `/pages/choujiang/index1?option=${param}`
					})
					// uni.navigateTo({
					// 	url: `/pages/index/extractionBlindbox?id=${item.id}`
					// });
				}
			},
			getBlindboxlist() {
				this.$api
					.activity_list_index({

					})
					.then(res => {
						this.blindBoxList = res.map(item => {
							item.legend_goods.forEach(good => {
								good.cover_image = 'https://mh.mytshop.cn' + good.cover_image
							})
							item.legend_goods = item.legend_goods.splice(0, 4)
							return item
						});
					});
			},

		}
	}
</script>

<style scoped lang="scss">
	.choujiang {
		width: 100vw;
		height: 100vh;
		overflow-y: auto;
		background-image: url('@/static/images/newhone/bg12.png');
		background-repeat: no-repeat;
		background-size: cover;
		padding-bottom: 66px;
		padding-top: 450rpx;

		.prize {
			width: 200rpx;
			height: 200rpx;
			position: absolute;
			right: 130rpx;
			top: 100rpx;
			animation: fudong 3s infinite linear;
		}

		@keyframes fudong {
			0% {
				top: 90rpx;
			}

			50% {
				top: 110rpx;
			}

			100% {
				top: 90rpx;
			}
		}

		.tabs {
			width: 100%;
			color: #a3baec;
			display: flex;
			align-items: center;
			padding: 0 100rpx;
			box-sizing: border-box;
			position: absolute;
			left: 0;
			top: 400rpx;

			.li {
				font-size: 30rpx;
				margin-right: 60rpx;
			}

			.active {
				color: #ddf3f9;
			}
		}

		.noticeBox {
			width: 50vw;
			height: 170rpx;
			position: absolute;
			left: 30rpx;
			top: 200rpx;

			swiper-item {
				height: 60rpx !important;
				padding-top: 10rpx;
				display: flex;
				align-items: center;

				.item {
					height: 100%;
					font-size: 24rpx;
					padding: 0 15rpx;
					display: flex;
					align-items: center;
					background: linear-gradient(to right, #93defd, #c1e3f6, #93defd);
					border: 2rpx solid #6684ec;

					.avatar {
						width: 45rpx;
						height: 45rpx;
						border-radius: 50%;
						margin-right: 10rpx;
					}

					.name {
						display: inline-block;
						width: 230rpx;
						height: 50rpx;
						line-height: 50rpx;
						overflow: hidden;
						color: #333;
					}

					.type {
						height: 100%;
						color: #b13d4c;
						// padding-left: 15rpx;
						// border-left: 2rpx solid #6684ec;
						display: flex;
						align-items: center;
						justify-content: center;
					}

				}
			}
		}

		@keyframes identifier {
			0% {
				transform: translateY(0);
			}

			99% {
				transform: translateY(100);
			}

			100% {
				transform: translateY(0);
			}
		}

		.scrollView {
			height: calc(100vh - 430rpx - 76px);

			.list {
				width: 735rpx;
				height: 302rpx;
				background-image: url('@/static/images/newhone/bg11.png');
				background-repeat: no-repeat;
				background-size: cover;
				margin: auto;
				padding: 34rpx;
				box-sizing: border-box;
				display: flex;
				align-items: center;
				justify-content: space-between;

				.l {
					margin-right: 22rpx;

					image {
						width: 236rpx;
						height: 236rpx;
					}
				}

				.r {
					.name {
						font-size: 26rpx;
						font-family: PingFang SC;
						font-weight: bold;
						color: #1E1E1E;
					}

					.price {
						font-size: 26rpx;
						font-family: PingFang SC;
						font-weight: bold;
						color: #1E1E1E;
						margin: 5rpx 0 10rpx;
					}

					.prob {
						font-size: 22rpx;
						font-family: PingFang SC;
						color: #888888;
						display: flex;
						align-items: center;
						justify-content: space-between;
					}

					.goods {
						display: flex;
						align-items: center;
						justify-content: space-between;
						margin-top: 20rpx;

						image {
							width: 82rpx;
							height: 82rpx;
							margin-right: 22rpx;
						}
					}

				}
			}
		}
	}
</style>
